package app;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.JProgressBar;
import javax.swing.JLabel;
import javax.swing.ImageIcon;

public class ProgressBarThread extends JFrame implements Runnable{

	private static final long serialVersionUID = 1L;
	private JPanel contentPane;
	Integer flag;
	
	public ProgressBarThread(Integer flag) {
		super();
		this.flag = flag;
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 282, 140);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		contentPane.setLayout(null);
		
		JProgressBar progressBar = new JProgressBar();
		progressBar.setBounds(10, 48, 253, 23);
		contentPane.add(progressBar);
		
		JLabel lblNewLabel = new JLabel("La transacci\u00F3n esta siendo procesada...");
		lblNewLabel.setBounds(56, 11, 207, 26);
		contentPane.add(lblNewLabel);
		
		JLabel label = new JLabel("");
		label.setIcon(new ImageIcon(ProgressBarThread.class.getResource("/icons/n_refresh_result.png")));
		label.setBounds(16, 11, 30, 26);
		contentPane.add(label);
		this.setVisible(false);
	}

	@Override
	public void run() {
		this.setVisible(true);
		while(flag!=0);
		this.setVisible(false);
	}
}
